﻿// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System.ComponentModel;
using Microsoft.Windows.Design.Metadata;
using Microsoft.Windows.Design.PropertyEditing;

[assembly: ProvideMetadata(typeof(Expression.Samples.PathListBoxUtils.Design.MetadataStore))]
namespace Expression.Samples.PathListBoxUtils.Design
{
	public class MetadataStore : IProvideAttributeTable
	{
		private readonly string CommonCategoryName = "Common Properties";

		public AttributeTable AttributeTable
		{
			get
			{
				AttributeTableBuilder attributeTableBuilder = new AttributeTableBuilder();

				#region PathListBoxItemTransformer

				string categoryName = "Item Transformer";

				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "OpacityRange",
					new CategoryAttribute(categoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "ScaleRange",
					new CategoryAttribute(categoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "AngleRange",
					new CategoryAttribute(categoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "UseGlobalOffset",
					new CategoryAttribute(categoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "Shift",
					new CategoryAttribute(categoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "IsCentered",
					new CategoryAttribute(categoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "Ease",
					new CategoryAttribute(categoryName));

				PropertyOrder lastInsertedOrder = null;
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "OpacityRange",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(PropertyOrder.Default)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "ScaleRange",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "AngleRange",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "Ease",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "Shift",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "IsCentered",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer), "UseGlobalOffset",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));
				
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"OpacityRange", new DescriptionAttribute("Gets or sets the range of values to use for the opacity."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"OpacityRange", new NumberRangesAttribute(0, 0, 1, 1, false));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"OpacityRange", new NumberIncrementsAttribute(.01, .1, .1));

				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"ScaleRange", new DescriptionAttribute("Gets or sets the range of values to use for the scale."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"ScaleRange", new NumberIncrementsAttribute(.01, .1, .1));
				
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"AngleRange", new DescriptionAttribute("Gets or sets the range of angle values to add to the rotation."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"AngleRange", new NumberIncrementsAttribute(0.1, 1, 10));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"AngleRange", new NumberRangesAttribute(0, 0, 360, 360, false));
				

				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"UseGlobalOffset", new DescriptionAttribute("Gets or sets whether to use adjust the offset across all paths by using the GlobalOffset instead of LocalOffset as the starting offset for the item."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"IsCentered", new DescriptionAttribute("Gets or sets whether to adjust the offset evenly from the center of the path."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"Ease", new DescriptionAttribute("Gets or sets the easing function that is used to adjust the offset."));

				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"Shift", new DescriptionAttribute("Gets or sets the amount to shift the offset from the beginning of the path."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"Shift", new NumberIncrementsAttribute(.001, .01, .1));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxItemTransformer),
					"Shift", new NumberRangesAttribute(0, 0, 1, 1, false));
				#endregion

				#region PathListBoxScrollBehavior
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "Duration",
					new CategoryAttribute(this.CommonCategoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "Ease",
					new CategoryAttribute(this.CommonCategoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "Increment",
					new CategoryAttribute(this.CommonCategoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "HideEnteringItem",
					new CategoryAttribute(this.CommonCategoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "SelectedItemPosition",
					new CategoryAttribute(this.CommonCategoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "Amount",
					new CategoryAttribute(this.CommonCategoryName));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "DesiredOffset",
					new CategoryAttribute(this.CommonCategoryName));
				
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "Amount",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(PropertyOrder.Default)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "Duration",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "Ease",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "DesiredOffset",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior), "HideEnteringItem",
					new PropertyOrderAttribute(lastInsertedOrder = PropertyOrder.CreateAfter(lastInsertedOrder)));

				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior),
					"Duration", new DescriptionAttribute("Gets or sets the duration of the scroll."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior),
					"Amount", new DescriptionAttribute("Gets or sets the amount to increment or decrement the StartItemIndex."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior),
					"Ease", new DescriptionAttribute("Gets or sets the easing function to use when scrolling."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior),
					"DesiredOffset", new DescriptionAttribute("Gets or sets the offset from 0 to 1 along the layout paths associated with this PathListBox to scroll the selected item."));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior),
					"DesiredOffset", new NumberIncrementsAttribute(.001, .01, .1));
				attributeTableBuilder.AddCustomAttributes(typeof(PathListBoxScrollBehavior),
					"HideEnteringItem", new DescriptionAttribute("Gets or sets whether to hide the item that will be newly arranged on the path when the StartItemIndex is changed. Use this when scrolling on an open path."));
				#endregion

				return attributeTableBuilder.CreateTable();
			}
		}
	}
}
